/*-----------------
    图片翻页
------------------*/
define(function(require,exports,module){
	var $ = require("$");
	function ImgMore(container,target){
		this.$container = jQuery(container);//图片容器
		this.$pre = this.$container.find(".imgs-more-left");//上一页
		this.$next = this.$container.find(".imgs-more-right");//下一页
		this.target = target;//下一页
		this.$page = this.$container.find("div.imgs-more-nav>span>b")
		this._index = 1;
	}
	module.exports = ImgMore;
	
	ImgMore.prototype.pre = function(){
		var that = this; 
		var target = that.target;
		that.$pre.click(function(){
            that._index--;
			if (that._index>1){
                that.$pre.removeClass("nopre");
                that.$next.removeClass("nonext");
			}else{
                that._index=1
                that.$pre.addClass("nopre");
			}
            jQuery(target).eq(that._index-1).removeClass("fn-hide").siblings(target).addClass("fn-hide");
            that.$page.text(that._index)
		});
	}
	ImgMore.prototype.next = function(){
		var that = this; 
		var target = that.target;
		that.$next.click(function(){
            that._index++;
			if (that._index<5){
                that.$next.removeClass("nonext");
                that.$pre.removeClass("nopre");
			}else{
                that._index=5
                that.$next.addClass("nonext");
			}
            jQuery(target).eq(that._index-1).removeClass("fn-hide").siblings(target).addClass("fn-hide");
            that.$page.text(that._index)
		});
	}
	
});